﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TAdSetupInfo2.aspx.cs" Inherits="adsetup_TAdSetupInfo2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
 <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery0905.js" type="text/javascript"></script>
    <script src="../js/jqModal.js" type="text/javascript"></script>  
    <script language="JScript" src="../js/myCheck.js"></script>
      <link href="../css/pagebox.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" language="javascript">  
    
    function NotCharacter(str,name)
    {
        var vstr =/^[A-Za-z0-9]+$/;
        if(!vstr.test(str)){
        alert(name+"必须是字母或数字!");
        return false;}
    }
    
    function chk() 
	{
        $('#txtInfoId').val($.trim( $('#txtInfoId').val()));
        $('#txtName').val($.trim( $('#txtName').val()));
        $('#txtOrder').val($.trim( $('#txtOrder').val()));
       
		if(CheckText(form1.txtInfoId,"编码",30)==false) return false;
		if(NotCharacter(form1.txtInfoId.value,"编码")==false) return false;
		if(CheckText(form1.txtName,"二级名称",10)==false) return false;
		if(CheckNum(form1.txtOrder,"排序")==false) return false;

		return true;
	}
   
    
    $().ready(function() {
        $('#divInput').jqm({modal: true,trigger: '#btnAdd'});
        
    });
    var opration="";
   
    function showdiv()
    {
        $('#divInput').jqmShow(); 
    }
    function inputbind(strid)
    {
        $('#tdtitle').text("修改");
        var urlstring="tadsetupinfo2.aspx";
            $.ajax({
            url:urlstring,
            type:'post',
            dataType:'html',
            data:'&opration=bind&id='+ strid ,
            beforeSend:function()
            {
               
            },
            error:function()
            {
               
            },
            success: function(msg)
            {
                var val=msg.split(',');
                $('#txtInfoId').val(val[0]);
                
                $('#txtName').val(val[1]);
                
                if(val[2]==0)
                    $('#chkShow').attr("checked",false);
                else
                    $('#chkShow').attr("checked",true);
                
                $('#txtOrder').val(val[3]);
                $('#divInput').jqmShow(); 
                opration='edit';
                $('#txtInfoId').attr('disabled',true);
                
            }
            });
    }
    
    function save()
    {
        
        if(!chk())return;
         if(opration=="")
            opration="save";
            var urlstring="tadsetupinfo2.aspx";
            $.ajax({
            url:urlstring,
            type:'post',
            dataType:'html',
            data:'&opration='+opration+'&id='+ escape($('#txtInfoId').val())+ "&type=" + $('#spanlab').text() +"&name="+ escape($('#txtName').val()) + "&show=" +$('#chkShow').attr("checked") +"&Order="+$('#txtOrder').val(),
            beforeSend:function()
            {
            },
            error:function()
            {
               
            },
            success: function(msg)
            {
                if(msg=="")
                {
                    $('#divInput').jqmHide(); 
                    opration='';
                    $('#txtInfoId').attr('disabled',false);
                    location.href="tadsetupinfo2.aspx?typeid=" + $('#spanlab').text() ;
                }
                else
                {
                    alert(msg);
                }
            }
            });
    }
    
   function del(strid)
    {
        var urlstring="tadsetupinfo2.aspx";
            $.ajax({
            url:urlstring,
            type:'post',
            dataType:'html',
            data:'&opration=del&id='+ strid ,
            beforeSend:function()
            {
               
            },
            error:function()
            {
               
            },
            success: function(msg)
            {
                opration='edit';
                $('#txtInfoID').attr('disabled',true);
                location.href="tadsetupinfo2.aspx?typeid=" + $('#spanlab').text();
            }
            });
    }
    function clearin()
    {
        
        $(".in").val('');
        $('#chkShow').attr('checked',true);
        $('#tdtitle').text("添加");
    }

    </script>
</head>
<body >
    <form id="form1" runat="server">
     <div id="divInput" class="jqmWindow" style="display:none; left: 63%; width: 270px; top: 14%;">
        <table width='100%' style ="background-color:#0075b0">
            <tr>
                <td align="left" id='tdtitle' style="font-size:12px;color:White"></td><td align="right" ><asp:ImageButton ID="btnPanel2Cancel" runat="server" ImageUrl="~/adsetup/images/close.png" CausesValidation='false' OnClick="btnPanel2Cancel_Click" /></td>
            </tr>
        </table>
        <br />
        <table width='100%'>
            <tr>
                <td align="right" >编码:</td>
                <td><asp:TextBox CssClass='in' ID='txtInfoId' runat="server" ></asp:TextBox></td>
            </tr>
            <tr>
                <td align="right">二级名称:</td>
                <td><asp:TextBox CssClass='in' ID='txtName' runat="server" ></asp:TextBox></td>
            </tr>
      
            <tr>
                <td align="right">是否显示:</td>
                <td><asp:CheckBox ID='chkShow' Text='显示' runat="server"  /></td>
            </tr>
        
        
            <tr>
                <td align="right">排序:</td>
                <td><asp:TextBox CssClass='in' ID='txtOrder' runat="server"></asp:TextBox></td>
            </tr>
            <tr>
                <td colspan='2' align="center">
                    <input type="button" id='btnSave1' value='保存' style="background-color:#296CB3; color:White ; width:50px; height:20px;" onclick ="save()" />
                    
                    
                </td>
            </tr>
        </table>
       <br />
   </div>
   
    <div>
       <table cellSpacing="0" cellPadding="0" border="0" align="center">
		    <tr>
		        <td style="background-color:White;padding-right: 10px; padding-left: 10px; padding-bottom: 10px; padding-top: 10px;">
		            <table cellSpacing="0" cellPadding="0" width="600" align="center" border="0" style="background-color:White;">
		                <tr>
		                    <td style="BORDER-RIGHT: #90b0de 1px solid; BORDER-TOP: #90b0de 1px solid; BORDER-LEFT: #90b0de 1px solid; BORDER-BOTTOM: #90b0de 1px solid">
		                        <table width="100%" cellSpacing="0" cellPadding="0" align="center" border="0">
		                            <tr height="30">
		                                <td style="border-bottom: #90b0de 1px solid; background-color: #ecf5ff; font-weight: bold; color: #004499; border-top-width: 1px; border-left-width: 1px; border-left-color: #90b0de; border-top-color: #90b0de; border-right-width: 1px; border-right-color: #90b0de;">&nbsp;&nbsp;&nbsp;<a href="TAdSetupInfo1.aspx">  <%=typename %> > (<span id='spanlab' runat="server" ></span>)</a></td>
		                            </tr>
		                        </table>
                             
                               
                                
                                
                                <div id="Div1" style="margin-top:10px;margin-bottom:0px;margin-left:10px;">
		                            <table cellSpacing="0" cellPadding="0" width="100%" border="0">
			                            <tr>
				                            <td height="24">
                                                <asp:button Width='50' id="btnAdd" runat="server" Height='20' Text="添加" CausesValidation="false" OnClientClick='clearin()' ForeColor="White" BackColor="#296CB3"  ></asp:button>
				                            </td>
			                            </tr>
		                            </table>
                                </div>
                                <div id="mnglist" style="margin-top:10px;margin-bottom:10px;margin-left:10px;margin-right:10px;">
                                    <asp:GridView Font-Size='13px' ID="dlTable" runat="server" AlternatingRowStyle-BackColor ='#ECF5FF'  SelectedRowStyle-BackColor="#cee5fd" Width="100%" AutoGenerateColumns="False" OnRowCommand="dlTable_RowCommand" GridLines="None"  >
                                        <Columns>
                                            <asp:TemplateField HeaderText ="编码">
                                                <ItemTemplate>
                                                    <a href='javascript:void(0)' style= "color:#004499" onclick ='javascript:opration="edit";inputbind("<%#Eval("infoid") %>")'><%#Eval("infoid") %></a>
                                                </ItemTemplate>
                                                <ItemStyle HorizontalAlign="Center" Width='80px' />
                                                <HeaderStyle HorizontalAlign="Center"  Width='80px' />
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="typename" HeaderText="分类" >
                                                <ItemStyle HorizontalAlign="Center" Width='80px' />
                                                <HeaderStyle HorizontalAlign="Center"  Width='80px' />
                                            </asp:BoundField>
                                            <asp:BoundField DataField="infoname" HeaderText="二级名称" >
                                                <ItemStyle HorizontalAlign="Center" Width='80px' />
                                                <HeaderStyle HorizontalAlign="Center"  Width='80px' />
                                            </asp:BoundField>
                                             <asp:TemplateField  HeaderText="是否显示">
                                                <ItemTemplate>
                                                    <label id='labshow' runat="server" ><%#(Eval("isshow").ToString()=="0")?"N":"Y" %></label>
                                                </ItemTemplate>
                                                <ItemStyle HorizontalAlign="Center" Width='80px' />
                                                 <HeaderStyle HorizontalAlign="Center"  Width='80px' />
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="orderby" HeaderText="排序" >
                                                <ItemStyle HorizontalAlign="Center" Width='80px' />
                                                <HeaderStyle HorizontalAlign="Center"  Width='80px' />
                                            </asp:BoundField>
                                            <asp:TemplateField HeaderText="删除">
                                                <ItemTemplate>
                                                    <asp:linkbutton id="lbDelete" ForeColor ='#004499' runat="server" CommandName="Del" CommandArgument='<%#Eval("infoid") %>'><img border="0" src="./images/del.gif" alt="删除" onClick="javascript:{return confirm('删除操作不可恢复，确认吗？');}"></asp:linkbutton>
                                                </ItemTemplate>
                                                <ItemStyle HorizontalAlign="Center" Width='80px' />
                                                <HeaderStyle HorizontalAlign="Center"  Width='80px' />
                                            </asp:TemplateField>
                                           
                                        </Columns>
                                        <SelectedRowStyle BackColor="#CEE5FD" />
                                        <AlternatingRowStyle BackColor="#ECF5FF" />
                                        <RowStyle  Height='20px' />
                                     </asp:GridView>
                                     <%=pager%>
                                </div>
		                    </td>
		                </tr>
		            </table>
		        </td>
		    </tr>
		</table>
    </div>
    </form>
</body>
</html>